* Updated: 2025 10 01

cap log close
log using logfile.log, replace

clear
est clear

* rhs variables
global rhs1 "cig_tax tob21 ecig_mlsa ecig_work_ban ecig_rest_ban ecig_bar_ban cig_work_ban cig_rest_ban cig_bar_ban ecig_lic tob_lic ban_ecigs tob_cigar_tax_st tob_littlecigar_tax_st tob_cigar_tax_percent_st tob_littlecigar_tax_percent_st tob_cigar_cap tob_littlecigar_cap pop_vary"

global rhs2 "cig_tax tob21 ecig_mlsa ecig_work_ban ecig_rest_ban ecig_bar_ban cig_work_ban cig_rest_ban cig_bar_ban ecig_lic tob_lic ban_ecigs tob_cigar_tax_st tob_littlecigar_tax_st tob_cigar_tax_percent_st tob_littlecigar_tax_percent_st tob_cigar_cap tob_littlecigar_cap pop_vary marij_mml_st marij_receffect_st medicaid_expansion mcaid_gum mcaid_loz mcaid_patch"

* main set of controls
global rhs3 "tob21 ecig_mlsa ecig_work_ban ecig_rest_ban ecig_bar_ban ban_ecigs ecig_lic cig_work_ban cig_rest_ban cig_bar_ban cig_tax tob_lic tob_cigar_tax_st tob_littlecigar_tax_st tob_cigar_tax_percent_st tob_littlecigar_tax_percent_st tob_cigar_cap tob_littlecigar_cap pop_vary medicaid_expansion mcaid_gum mcaid_loz mcaid_patch marij_mml_st marij_receffect_st demo_age_st demo_female_st demo_edu_somecoll_st demo_edu_coll_st demo_edu_grad_st"

* no population
global rhs4 "cig_tax tob21 ecig_mlsa ecig_work_ban ecig_rest_ban ecig_bar_ban cig_work_ban cig_rest_ban cig_bar_ban ecig_lic tob_lic ban_ecigs tob_cigar_tax_st tob_littlecigar_tax_st tob_cigar_tax_percent_st tob_littlecigar_tax_percent_st tob_cigar_cap tob_littlecigar_cap  marij_mml_st marij_receffect_st medicaid_expansion mcaid_gum mcaid_loz mcaid_patch demo_age_st demo_female_st demo_edu_somecoll_st demo_edu_coll_st demo_edu_grad_st"

global rhs_all "tob21 ecig_mlsa ecig_work_ban ecig_rest_ban ecig_bar_ban ban_ecigs ecig_lic cig_tax cig_work_ban cig_rest_ban cig_bar_ban tob_lic tob_cigar_tax_st tob_littlecigar_tax_st tob_cigar_tax_percent_st tob_littlecigar_tax_percent_st tob_cigar_cap tob_littlecigar_cap  medicaid_expansion mcaid_gum mcaid_loz mcaid_patch marij_mml_st marij_receffect_st  demo_age_st demo_female_st demo_male_st demo_edu_underHS_st demo_edu_HS_st demo_edu_somecoll_st demo_edu_coll_st demo_edu_grad_st"

* event time variables
global es_ecig "time_m8 time_m7 time_m6 time_m5 time_m4 time_m3 time_m2 o.time_m1 time_p0 time_p1 time_p2 time_p3 time_p4 time_p5 time_p6 time_p7 time_p8"
global es_ecig_fig "time_m8 time_m7 time_m6 time_m5 time_m4 time_m3 time_m2 time_m1 time_p0 time_p1 time_p2 time_p3 time_p4 time_p5 time_p6 time_p7 time_p8"

global es_ecig_calls "time_m4 time_m3 time_m2 o.time_m1 time_p0 time_p1 time_p2 time_p3 time_p4"
global es_ecig_calls_fig "time_m4 time_m3 time_m2 time_m1 time_p0 time_p1 time_p2 time_p3 time_p4"

* tax and sales variables for summary statistics tables
global sum_stats "ends nrt ecig_tax_county ends_price $rhs_all"

* table formatting
global formata "mtitles("E-cigarettes") addnote("Notes: All regressions estimated with OLS and control for time-varying area characteristics, store fixed effects, and period fixed effects.  95% confidence intervals that account for within-locality clustering reported in square brackets. ***,**, and * = statistically different from zero at the 1%, 5%, and 10% level.") c(b(star fmt(%9.1fc)) ci(par fmt(%9.1fc))) starl(* 0.10 ** 0.05 *** 0.01) l stats(N y_pre_treat etax, fmt(0 0 2)) replace compress"

global formatc "mtitles("NRT" ) addnote("Notes: All regressions estimated with OLS and control for time-varying area characteristics, store fixed effects, and period fixed effects unless otherwise noted.  95% confidence intervals that account for within-locality clustering reported in square brackets. ***,**, and * = statistically different from zero at the 1%, 5%, and 10% level.") c(b(star fmt(%9.1fc)) ci(par fmt(%9.1fc))) starl(* 0.10 ** 0.05 *** 0.01) l stats(N y_pre_treat etax, fmt(0 0 2)) replace compress"

global formatd "mtitles("Gum" "Lozenge" "Patch" "Brand" "Generic") addnote("Notes: All regressions estimated with OLS and control for time-varying area characteristics, store fixed effects, and period fixed effects.  95% confidence intervals that account for within-locality clustering reported in square brackets. ***,**, and * = statistically different from zero at the 1%, 5%, and 10% level.") c(b(star fmt(%9.1fc)) ci(par fmt(%9.1fc))) starl(* 0.10 ** 0.05 *** 0.01) l stats(N y_pre_treat etax, fmt(0 0 2)) replace compress"

global formate "mtitles("Prescriptions for cessation medications") addnote("Notes: All regressions estimated with OLS and control for time-varying state characteristics, state fixed effects, and period fixed effects.   Data are weighted by the state population. 95% confidence intervals that account for within-locality clustering reported in square brackets. ***,**, and * = statistically different from zero at the 1%, 5%, and 10% level.") c(b(star fmt(%9.1fc)) ci(par fmt(%9.1fc))) starl(* 0.10 ** 0.05 *** 0.01) l stats(N y_pre_treat etax, fmt(0 0 2)) replace compress"

global formatf "mtitles("Quitline calls") addnote("Notes: All regressions estimated with OLS and control for time-varying state characteristics, state fixed effects, and period fixed effects.   Data are weighted by the state population. 95% confidence intervals that account for within-locality clustering reported in square brackets.***,**, and * = statistically different from zero at the 1%, 5%, and 10% level.") c(b(star fmt(%9.1fc)) ci(par fmt(%9.1fc))) starl(* 0.10 ** 0.05 *** 0.01) l stats(N y_pre_treat etax, fmt(0 0 2)) replace compress"

global formatg "mtitles("Try to quit" "Successful quit" "Unsuccessful quit" "Any vaping" "Daily vaping") addnote("Notes: All regressions estimated with OLS and control for time-varying state characteristics, state fixed effects, and period fixed effects.  Data are weighted by BRFSS-provided weights.  95% confidence intervals that account for within-locality clustering reported in square brackets. ***,**, and * = statistically different from zero at the 1%, 5%, and 10% level.") c(b(star fmt(%9.3fc)) ci(par fmt(%9.3fc))) starl(* 0.10 ** 0.05 *** 0.01) l stats(N y_pre_treat etax, fmt(0 2 2)) replace compress"

********************************************************************************
*                                   Nielsen                                    *
********************************************************************************
u "workingdata/nrt_tax_clean_stores", clear
sum ecig_tax_county
sum ecig_tax_county if ecig_tax_county != 0
su nrt_gum_price nrt_loz_price nrt_patch_price

* FIGURE 2: nominal taxes over time in jurisdictions that adopted an e-cigarette tax by 2021 Q4

u "workingdata/nrt_tax_clean_stores", clear

drop if mi(eff_time)
keep ecig_tax_county_nom state year quarter
duplicates drop

collapse (mean) ecig_tax_county_nom, by(state year) fast

sort state year

tw (connected ecig_tax_county_nom year),  yti("Average e-cigarette tax", color(black) size(small)) xti("", color(black) size(small)) xlabel(2010(1)2021, angle(45)) by(state) scheme(s1mono)
graph export "output/fg2.png", replace

********************************************************************************
* FIGURE 3: trends in e-cigarette taxes

u "workingdata/nrt_tax_clean_stores", clear

keep ecig_tax_county cig_tax year quarter fips
duplicates drop

collapse (mean) ecig_tax_county cig_tax, by(year) fast
tw (sc ecig_tax_county year, c(l) lcolor(black) lpattern(solid) mcolor(black)), ti("", color(black)) xti("") yti("E-cigarette tax", size(small)) xlabel(2010(1)2021, valuelabel labsize(small)) xmtick(2010(1)2021) leg(off) scheme(s1mono) 
graph save "temp/ecig_tax_trends", replace

tw (sc cig_tax year, c(l) lcolor(black) lpattern(dash) mcolor(black) ms(d)), ti("", color(black)) xti("") yti("Cigarette tax", size(small)) xlabel(2010(1)2021, valuelabel labsize(small)) xmtick(2010(1)2021) leg(off) scheme(s1mono)
graph save "temp/cig_tax_trends", replace

graph combine "temp/ecig_tax_trends" "temp/cig_tax_trends", scheme(s1mono) row(2) ti("", color(black) size(medium))

graph export "output/fg3.png", replace

********************************************************************************
* TABLE 1: Summary statistics: NielsenIQ retail sales 2010-2021

u "workingdata/nrt_tax_clean_stores", clear

* mean tax conditional on any tax
su ecig_tax_county if ecig_tax_county != 0

* prices of the NRT types
su nrt_gum_price nrt_loz_price nrt_patch_price, sep(100)

estpost sum $sum_stats
est sto table1_1
estpost sum $sum_stats if (time < eff_time) & !ni(eff_time)
est sto table1_2
estpost sum $sum_stats if mi(eff_time)
est sto table1_3
esttab table1* using "output/table1", title("Summary statistics: Neilson data 2010-2021") cells("mean(fmt(a2))") mtitles("All localities" "Localities that adopt an e-cigarette tax, pre-tax" "Localities that do not adopt an e-cigarette tax") l replace

********************************************************************************
* TABLE 2: Effect of e-cigarette taxes on e-cigarette sales using a two-way fixed effects regression: NielsenIQ retail sales data 2011-2021

u "workingdata/nrt_tax_clean_stores", clear

lab var ecig_tax_county "E-cigarette tax"

xi: reghdfe ends ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto table2_nrt
su ends if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county if !mi(ends)
estadd scalar etax = r(mean)

esttab table2* using "output/table2", ti("Effect of e-cigarette taxes on e-cigarette sales (full specification): NeilsonIQ retail sales data 2011-2021") keep(ecig_tax_county) $formata

* DCDH
keep if periods == 48

recode ecig_tax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn ends fips time tax_recast, effects(8) placebo(8) controls($rhs3) graph_off

********************************************************************************
* TABLE 3: Effect of e-cigarette taxes on NRT sales using a TWFE regression: NielsenIQ retail sales data 2010-2021

u "workingdata/nrt_tax_clean_stores", clear

reghdfe nrt ecig_tax_county, cl(fips) ab(store_code_uc time)
est sto A
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
esttab A using "output/table3_1", $formatc ti("Effect of e-cigarette taxes on NRT sales (locality and time FE only): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

xi: reghdfe nrt ecig_tax_county $rhs1, cl(fips) ab(store_code_uc time)
est sto B
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
esttab B using "output/table3_2", $formatc ti("Effect of e-cigarette taxes on NRT sales (add in tobacco control policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

xi: reghdfe nrt ecig_tax_county $rhs2, cl(fips) ab(store_code_uc time)
est sto C
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
esttab C using "output/table3_3", $formatc ti("Effect of e-cigarette taxes on NRT sales (add in other policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto D
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
ppmlhdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time) d
margins, dydx(ecig_tax_county)
esttab D using "output/table3_4", $formatc ti("Effect of e-cigarette taxes on NRT sales (add in demographics, full specification): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

********************************************************************************
* TABLE A1

u "workingdata/nrt_tax_clean_stores", clear

xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto tablea1
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)

esttab tablea1 using "output/tablea1", $formatc ti("Effect of e-cigarette taxes on NRT sales (add in demographics, full specification): NeilsonIQ retail sales data 2010-2020") keep(ecig_tax_county $rhs3)

********************************************************************************
* TABLE A2

u "workingdata/nrt_tax_clean_stores", clear

reghdfe nrt_mg_adj ecig_tax_county, cl(fips) ab(store_code_uc time)
est sto A
su nrt_mg_adj if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
esttab A using "output/tablea2_1", $formatc ti("Effect of e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (locality and time FE only): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

xi: reghdfe nrt_mg_adj ecig_tax_county $rhs1, cl(fips) ab(store_code_uc time)
est sto B
su nrt_mg_adj if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
esttab B using "output/tablea2_2", $formatc ti("Effect of e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in tobacco control policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

xi: reghdfe nrt_mg_adj ecig_tax_county $rhs2, cl(fips) ab(store_code_uc time)
est sto C
su nrt_mg_adj if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
esttab C using "output/tablea2_3", $formatc ti("Effect of e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in other policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

xi: reghdfe nrt_mg_adj ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto D
su nrt_mg_adj if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county
estadd scalar etax = r(mean)
ppmlhdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time) d
margins, dydx(ecig_tax_county)
esttab D using "output/tablea2_4", $formatc ti("Effect of e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in demographics, full specification): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

keep if periods == 48
recode ecig_tax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn nrt_mg_adj fips time tax_recast, effects(9) placebo(7) controls($rhs3) graph_off

********************************************************************************
* Appendix Table 4: Open system

u "workingdata/nrt_tax_clean_stores", clear

reghdfe nrt ecig_opentax_county, cl(fips) ab(store_code_uc time)
est sto A
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_opentax_county
estadd scalar etax = r(mean)
esttab A using "output/tablea4_1", $formatc ti("Effect of open system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (locality and time FE only): NeilsonIQ retail sales data 2010-2021") keep(ecig_opentax_county)

xi: reghdfe nrt ecig_opentax_county $rhs1, cl(fips) ab(store_code_uc time)
est sto B
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_opentax_county
estadd scalar etax = r(mean)
esttab B using "output/tablea4_2", $formatc ti("Effect of open system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in tobacco control policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_opentax_county)

xi: reghdfe nrt ecig_opentax_county $rhs2, cl(fips) ab(store_code_uc time)
est sto C
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_opentax_county
estadd scalar etax = r(mean)
esttab C using "output/tablea4_3", $formatc ti("Effect of open system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in other policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_opentax_county)

xi: reghdfe nrt ecig_opentax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto D
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_opentax_county
estadd scalar etax = r(mean)
ppmlhdfe nrt ecig_opentax_county $rhs3, cl(fips) ab(store_code_uc time) d
margins, dydx(ecig_opentax_county)
esttab D using "output/tablea4_4", $formatc ti("Effect of open system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in demographics, full specification): NeilsonIQ retail sales data 2010-2021") keep(ecig_opentax_county)

keep if periods == 48
recode ecig_opentax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn nrt fips time tax_recast, effects(9) placebo(7) controls($rhs3) graph_off

********************************************************************************
* Appendix Table 5: Closed system

u "workingdata/nrt_tax_clean_stores", clear

reghdfe nrt ecig_closedtax_county, cl(fips) ab(store_code_uc time)
est sto A
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_closedtax_county
estadd scalar etax = r(mean)
esttab A using "output/tablea5_1", $formatc ti("Effect of closed system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (locality and time FE only): NeilsonIQ retail sales data 2010-2021") keep(ecig_closedtax_county)

xi: reghdfe nrt ecig_closedtax_county $rhs1, cl(fips) ab(store_code_uc time)
est sto B
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_closedtax_county
estadd scalar etax = r(mean)
esttab B using "output/tablea5_2", $formatc ti("Effect of closed system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in tobacco control policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_closedtax_county)

xi: reghdfe nrt ecig_closedtax_county $rhs2, cl(fips) ab(store_code_uc time)
est sto C
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_closedtax_county
estadd scalar etax = r(mean)
esttab C using "output/tablea5_3", $formatc ti("Effect of closed system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in other policies): NeilsonIQ retail sales data 2010-2021") keep(ecig_closedtax_county)

xi: reghdfe nrt ecig_closedtax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto D
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su ecig_closedtax_county
estadd scalar etax = r(mean)
*ppmlhdfe nrt ecig_closedtax_county $rhs3, cl(fips) ab(store_code_uc time) d
*margins, dydx(ecig_closedtax_county)
esttab D using "output/tablea5_4", $formatc ti("Effect of closed system e-cigarette taxes on NRT sales adjusted for nicotine content per store-quarter (add in demographics, full specification): NeilsonIQ retail sales data 2010-2021") keep(ecig_closedtax_county)

keep if periods == 48
recode ecig_closedtax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn nrt fips time tax_recast, effects(9) placebo(7) controls($rhs3) graph_off

********************************************************************************
* FIGURE 6: effect of e-cigarette taxes on NRT sales using event study models (catch-all endpoints, -1 is omitted): NielsenIQ retail sales data 2010-2020

u "workingdata/nrt_tax_clean_stores", clear

xi: reghdfe nrt $es_ecig $rhs3 if (inrange(rel_time, -8, 8) | rel_time == .), cl(fips) ab(store_code_uc time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small)) ylabel(, labsize(small) angle(45)) ti("Trimmed endpoints", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
 
graph save "temp/nrt_trim_x_ecig_es", replace

xi: reghdfe nrt $es_ecig $rhs3, cl(fips) ab(store_code_uc time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small)) ylabel(, labsize(small) angle(45)) ti("Catch all endpoints", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted

graph save "temp/nrt_catch_x_ecig_es", replace

* DCDH
keep if periods == 48
recode ecig_tax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn nrt fips time tax_recast, effects(9) placebo(7) controls($rhs3) graph_off save_results("temp/nrt_dcdh")

u "temp/nrt_dcdh", clear

replace time = time - 1

tw (sc point time, color(black)) (rspike lb up time, color(black)), plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(-0.5, lcolor(black) lpattern(dash)) xlabel(-8(1)8, labsize(small)) xsc(range(-8.5 8.5)) ylabel(, labsize(small) angle(45)) xti("", color(black) size(medium)) ti("DCDH", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) legend(off)

graph save "temp/nrt_dcdh", replace

graph combine "temp/nrt_trim_x_ecig_es" "temp/nrt_catch_x_ecig_es" "temp/nrt_dcdh", note("-1 is the omitted category")  scheme(s1mono) row(2) ti("", color(black) size(medium)) col(1)
graph export "output/fg6.png", replace

********************************************************************************
* FIGURE 4 & 5: trends in e-cigarette & NRT sales, for states that adopt and do not adopt e-cigarette tax

u "workingdata/nrt_tax_clean_stores", clear

g ecig_tax_present = eff_time != .

collapse (mean) ends nrt any_nrt nrt_gum nrt_loz nrt_patch nrt_b nrt_pl, by(ecig_tax_present year)

reshape wide ends nrt any_nrt nrt_gum nrt_loz nrt_patch nrt_b nrt_pl, i(year) j(ecig_tax_present)

foreach var in ends nrt any_nrt nrt_gum nrt_loz nrt_patch nrt_b nrt_pl {
	rename `var'0 `var'_control
	rename `var'1 `var'_treat
}

tw (sc ends_treat year if inrange(year, 2011, 2021), ti("", color(black)) xti("") yti("ENDS sales per store", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)) (sc ends_control year if inrange(year, 2011, 2021), ti("", color(black)) xti("") yti("ENDS sales per store", size(small)) c(l) ylabel(, angle(45) labsize(small)) lcolor(black) lpattern(dash) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono)
graph export "output/fg4.png", replace

tw (sc nrt_treat year, ti("", color(black)) xti("") yti("NRT sales per store", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2010(1)2021,  valuelabel labsize(small) ) xmtick(2010(1)2021)) (sc nrt_control year, ti("", color(black)) xti("") yti("NRT sales per store", size(small)) c(l) ylabel(, angle(45) labsize(small)) lcolor(black) lpattern(dash) mcolor(black) xlabel(2010(1)2021, valuelabel labsize(small)) xmtick(2010(1)2021)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono)
graph export "output/fg5.png", replace

********************************************************************************
* FIGURE 7: alternative samples, hold the specification constant

u "workingdata/nrt_tax_clean_stores", clear

* main sample
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto A

* balanced sample
preserve
keep if periods == 48
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto B
restore

* sample that ever sold
preserve
keep if periods == 48
drop if periods_nrt == 0
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto H
restore

* balanced sample that ever sold
preserve
keep if periods == 48
drop if periods_nrt == 0
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto I
restore

* drop enactment period
preserve
drop if enact == 1
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto C
restore

* drop treated state localities
preserve
drop if (state == "IL" | state == "MD")
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto D
restore

* drop treated sub-state localities
preserve
drop if (state == "CookCo" | state == "MontCo")
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto E
restore

* drop 2020
preserve
drop if year == 2020
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto F
restore

* drop 2010
preserve
drop if year == 2010
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto G
restore

lab var ecig_tax_county "E-cigarette tax"

coefplot (A, label("Main sample (All Stores)")) (H, label(Stores ever sold NRT)) (B, label(Balanced sample)) (I, label(Balanced sample ever sold NRT))  (C, label(Drop enactment period))  (D, label(Drop IL & MD)) (E, label(Drop Cook & Montgomery counties)) (F, label(Drop 2020)) (G, label(Drop 2010)), keep(ecig_tax_county) scheme(s1mono) yline(0, lcolor(black)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) ylabel(, labsize(small) angle(45)) xline(0) xlabel("", labsize(medium))   ti("", color(black) size(medium))  xti("", color(black) size(vsmall)) yti("Treatment effect", color(black) size(small)) legend(col(2) fcolor(none) lcolor(none) rowgap(vsmall) colgap(vsmall) size(vsmall))

graph export "output/fg7.png", replace

estimates clear

********************************************************************************
* FIGURE 7: alternative specifications, hold the sample constant

u "workingdata/nrt_tax_clean_stores", clear

* main spec
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto A

* include division-by-quarter fixed effects
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc div_time)
est sto B

* control for the enactment period
xi: reghdfe nrt ecig_tax_county enact $rhs3, cl(fips) ab(store_code_uc time)
est sto C

* control for distance to the closest lower tax county
xi: reghdfe nrt ecig_tax_county $rhs3 ecig_taxlowdist_cnty ecig_taxlowdist_cnty_tax, cl(fips) ab(store_code_uc time)
est sto D

* weight by sales in Q1 and Q2 2010
xi: reghdfe nrt ecig_tax_county $rhs3 [aw=sales_2010], cl(fips) ab(store_code_uc time)
est sto F

* state-specific linear time trends
xi: reghdfe nrt ecig_tax_county $rhs3 i.fips*time, cl(fips) ab(store_code_uc time)
est sto H

* control for prices
xi: reghdfe nrt ecig_tax_county nrt_price $rhs3, cl(fips) ab(store_code_uc time)
est sto I

* control for covid
xi: reghdfe nrt ecig_tax_county covid_case covid_death covid_sch50 covid_closure $rhs3, cl(fips) ab(store_code_uc time)
est sto J

lab var ecig_tax_county "E-cigarette tax"

coefplot (A, label(Main specification))  (B, label(Control for division-by-time FE)) (H, label(Control for jurisdiction-specific time trend)) (C, label(Control for enactment period))  (D, label(Control for distance to lower e-cigarette tax county)) (J, label(Controls for COVID-19 cases & school/business closures)) (F, label(Weight by Q1 & Q2 2010 sales)), keep(ecig_tax_county) scheme(s1mono) yline(0, lcolor(black)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) ylabel(, labsize(small) angle(45)) xline(0) xlabel("", labsize(medium)) ti("", color(black) size(medium))  xti("", color(black) size(medium)) yti("Treatment effect", color(black) size(small)) legend(col(2) fcolor(none) lcolor(none) rowgap(vsmall) colgap(vsmall) size(vsmall))

graph export "output/fg8.png", replace

estimates clear

********************************************************************************
* FIGURE 8: leave one out anlaysis

u "workingdata/nrt_tax_clean_stores", clear

* main sample
xi: reghdfe nrt ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
est sto A

* drop CA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="CA", cl(fips) ab(store_code_uc time)
est sto B

* drop CO
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="CO", cl(fips) ab(store_code_uc time)
est sto C

* drop CT
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="CT", cl(fips) ab(store_code_uc time)
est sto D

* drop CookCo
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="CookCo", cl(fips) ab(store_code_uc time)
est sto E

* drop DC
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="DC", cl(fips) ab(store_code_uc time)
est sto F

* drop DE
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="DE", cl(fips) ab(store_code_uc time)
est sto G

* drop GA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="GA", cl(fips) ab(store_code_uc time)
est sto H
    	 
* drop IL
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="IL", cl(fips) ab(store_code_uc time)
est sto I

* drop KS
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="KS", cl(fips) ab(store_code_uc time)
est sto J

* drop KY
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="KY", cl(fips) ab(store_code_uc time)
est sto K

* drop LA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="LA", cl(fips) ab(store_code_uc time)
est sto L

* drop MA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="MA", cl(fips) ab(store_code_uc time)
est sto M

* drop MD
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="MD", cl(fips) ab(store_code_uc time)
est sto N

* drop ME
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="ME", cl(fips) ab(store_code_uc time)
est sto O

* drop MN
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="MN", cl(fips) ab(store_code_uc time)
est sto P

* drop MontCo
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="MontCo", cl(fips) ab(store_code_uc time)
est sto Q

* drop NC
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="NC", cl(fips) ab(store_code_uc time)
est sto R

* drop NH
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="NH", cl(fips) ab(store_code_uc time)
est sto S

* drop NJ
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="NJ", cl(fips) ab(store_code_uc time)
est sto T

* drop NM
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="NM", cl(fips) ab(store_code_uc time)
est sto U

* drop NV
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="NV", cl(fips) ab(store_code_uc time)
est sto V

* drop NY
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="NY", cl(fips) ab(store_code_uc time)
est sto W

* drop OH
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="OH", cl(fips) ab(store_code_uc time)
est sto X

* drop OR
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="OR", cl(fips) ab(store_code_uc time)
est sto Y

* drop PA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="PA", cl(fips) ab(store_code_uc time)
est sto Z

* drop UT
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="UT", cl(fips) ab(store_code_uc time)
est sto AA

* drop VA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="VA", cl(fips) ab(store_code_uc time)
est sto BB

* drop VT
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="VT", cl(fips) ab(store_code_uc time)
est sto CC

* drop WA
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="WA", cl(fips) ab(store_code_uc time)
est sto DD

* drop WI
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="WI", cl(fips) ab(store_code_uc time)
est sto EE

* drop WV
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="WV", cl(fips) ab(store_code_uc time)
est sto FF

* drop WY
xi: reghdfe nrt ecig_tax_county $rhs3 if state!="WY", cl(fips) ab(store_code_uc time)
est sto GG

lab var ecig_tax_county "E-cigarette tax"

coefplot (A, label(All)) (B, label(CA)) (C, label(CO)) (D, label(CT)) (E, label(Cook Co)) (F, label(DC)) (G, label(DE)) (H, label(GA)) (I, label(IL)) (J, label(KS)) (K, label(KY)) (L, label(LA)) (M, label(MA)) (N, label(MD)) (O, label(ME)) (P, label(MN)) (Q, label(Montgeomery Co)) (R, label(NC)) (S, label(NH)) (T, label(NJ)) (U, label(NM)) (V, label(NV)) (W, label(NY)) (X, label(OH)) (Y, label(OR)) (Z, label(PA)) (AA, label(UT)) (BB, label(VA)) (CC, label(VT)) (DD, label(WA)) (EE, label(WI)) (FF, label(WV)) (GG, label(WY)), keep(ecig_tax_county) scheme(s1mono) vertical ciopts(lcolor(black)) mcolor(black) levels(95) ylabel(, labsize(small) angle(45)) yline(0, lcolor(black)) xline(0) xlabel("", labsize(small)) ti("", color(black) size(medium)) xti(, color(black) size(small)) yti("Treatment effect", color(black) size(small)) legend(col(11) fcolor(none)  rowgap(vsmall) colgap(vsmall) lcolor(none) size(vsmall))

graph export "output/fg9.png", replace

********************************************************************************
* TABLE A3: Any tax

u "workingdata/nrt_tax_clean_stores", clear

recode ecig_tax_county (0=0) (0.0000/max=1), g(any_ecig_tax)

lab var any_ecig_tax "Any e-cigarette tax"

reghdfe nrt any_ecig_tax $rhs3, cl(fips) ab(store_code_uc time)
est sto tablea3
su nrt if inrange(rel_time, -1, -1)
estadd scalar y_pre_treat = r(mean)
su any_ecig_tax
estadd scalar etax = r(mean)

esttab tablea3 using "output/tablea3", $formatc ti("Effect of e-cigarette taxes on e-cigarette sales (full specification using a binary e-cigarette tax variable): NeilsonIQ retail sales data 2010-2020") keep(any_ecig_tax)

********************************************************************************
* TABLE 4 & 5: Heterogeneity in the effect of e-cigarette taxes on NRT sales using a two-way fixed effects regression: NielsenIQ retail sales data 2010-2020

u "workingdata/nrt_tax_clean_stores", clear

lab var ecig_tax_county "E-cigarette tax"

foreach zz in nrt_gum nrt_loz nrt_patch nrt_b nrt_pl {
	xi: reghdfe `zz' ecig_tax_county $rhs3, cl(fips) ab(store_code_uc time)
	est sto table45_`zz'
	su `zz' if inrange(rel_time, -1, -1)
	estadd scalar y_pre_treat = r(mean)
	su ecig_tax_county if !mi(`zz')
	estadd scalar etax = r(mean)
}
esttab table45* using "output/table45", $formatd ti("Heterogeneity in the effect of e-cigarette taxes on e-cigarette sales using stores observed in all 44 period (full specification): NeilsonIQ retail sales data 2010-2021") keep(ecig_tax_county)

********************************************************************************
*                                     SDUD                                     *
********************************************************************************
* TABLE 6: Effect of e-cigarette taxes on prescription RX for cessation medications using a two-way fixed effects regression: SDUD script data 2011-2021

u "workingdata/sdud_tax_clean", clear

* early Medicaid expansion
g early = 0
loc states "AR	CA	CO	CT	DE	DC	HI	IL	IA	KY	MD	MA	MN	NV	NJ	NM	NY	ND	OH	OR	RI	VT	WA	WV"
for zz in any `states': replace early = 1 if state == "zz"

lab var ecig_tax_county "E-cigarette tax" 

xi: reghdfe scripts_rate ecig_tax_county $rhs4 [aw=pop_vary], cl(fips) ab(fips time)
est sto table_6A
su scripts_rate if inrange(rel_time, -1, -1) [aw=pop_vary]
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county [aw=pop_vary]
estadd scalar etax = r(mean)

esttab table_6A using "output/table6_1", $formate ti("Effect of e-cigarette taxes on cessation medication prescriptions (all states)") keep(ecig_tax_county)

preserve
keep if early == 1

* early (January 1 2014) expansion states
xi: reghdfe scripts_rate ecig_tax_county $rhs4 [aw=pop_vary], cl(fips) ab(fips time)
est sto table_6B
su scripts_rate if inrange(rel_time, -1, -1) [aw=pop_vary]
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county [aw=pop_vary]
estadd scalar etax = r(mean)

esttab table_6B using "output/table6_2", $formate ti("Effect of e-cigarette taxes on cessation medication prescriptions (early [January 1 2014] expansion states)") keep(ecig_tax_county)

restore, preserve
keep if early == 0

* late expansion states and non-expansion states
xi: reghdfe scripts_rate ecig_tax_county $rhs4 [aw=pop_vary], cl(fips) ab(fips time)
est sto table_6C
su scripts_rate if inrange(rel_time, -1, -1) [aw=pop_vary]
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county [aw=pop_vary]
estadd scalar etax = r(mean)

esttab table_6C using "output/table6_3", $formate ti("Effect of e-cigarette taxes on cessation medication prescriptions (late expansion and non-expansion states)") keep(ecig_tax_county)

********************************************************************************
* FIGURE A1: trends over time in scripts for states that adopt and do not adopt an e-cigarette tax

u "workingdata/sdud_tax_clean", clear

g scripts_rate_treat = scripts_rate if eff_time != .
g scripts_rate_control = scripts_rate if eff_time == .

collapse (mean) scripts_rate scripts_rate_treat scripts_rate_control [aw=pop_vary], by(year) fast

tw (sc scripts_rate_treat year, ti("", color(black)) xti("") yti("Medicaid-financed prescription cessation medications", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2011(1)2021,  valuelabel labsize(small) ) xmtick(2011(1)2021)) (sc scripts_rate_control year, ti("", color(black)) xti("") yti("Medicaid-financed prescription cessation medications", size(small)) c(l) ylabel(, angle(45) labsize(small) ) lcolor(black) lpattern(dash) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono)
graph export "output/afg1.png", replace

********************************************************************************
* FIGURE A4

u "workingdata/sdud_tax_clean", clear

xi: reghdfe scripts_rate ecig_tax_county $rhs4 [aw=pop_vary], cl(fips) ab(fips time)
est sto table_7A
su scripts_rate if inrange(rel_time, -1, -1) [aw=pop_vary]
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county [aw=pop_vary]
estadd scalar etax = r(mean)

lab var ecig_tax_county "E-cigarette tax" 

xi: reghdfe scripts_rate $es_ecig $rhs4 [aw=pop_vary] if (inrange(rel_time, -8, 8) | rel_time == .), cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Trimmed endpoints", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
 
graph save "temp/scripts_trim_x_ecig_es", replace

xi: reghdfe scripts_rate $es_ecig $rhs4 [aw=pop_vary],  cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Catch all endpoints", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted

graph save "temp/scripts_catch_x_ecig_es", replace

* DCDH
u "workingdata/sdud_tax_clean", clear

* early Medicaid expansion
g early = 0
loc states "AR	CA	CO	CT	DE	DC	HI	IL	IA	KY	MD	MA	MN	NV	NJ	NM	NY	ND	OH	OR	RI	VT	WA	WV"
for zz in any `states': replace early = 1 if state == "zz"

recode ecig_tax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn scripts_rate fips time tax_recast, effects(9) placebo(7) controls($rhs4) weight(pop_vary) graph_off save_results("temp/sdud_dcdh")
did_multiplegt_dyn scripts_rate fips time tax_recast if early == 1, effects(9) placebo(7) controls($rhs4) weight(pop_vary) graph_off
did_multiplegt_dyn scripts_rate fips time tax_recast if early == 0, effects(9) placebo(7) controls($rhs4) weight(pop_vary) graph_off

u "temp/sdud_dcdh", clear

replace time = time - 1

tw (sc point time, color(black)) (rspike lb up time, color(black)), plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(-0.5, lcolor(black) lpattern(dash)) xlabel(-8(1)8, labsize(small)) xsc(range(-8.5 8.5)) ylabel(, labsize(small) angle(45)) xti("", color(black) size(medium)) ti("DCDH", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) legend(off)

graph save "temp/sdud_dcdh", replace

graph combine "temp/scripts_trim_x_ecig_es" "temp/scripts_catch_x_ecig_es" "temp/sdud_dcdh", note("-1 is the omitted category") scheme(s1mono) row(2) ti("", color(black) size(medium)) col(1)
graph export "output/afg4.png", replace

********************************************************************************
*                                   Quitline                                   *
********************************************************************************
* TABLE 7: Effect of e-cigarette taxes on calls to quitlines using a two-way fixed effects regression: CDC quitline calls data 2010-2020

u "workingdata/quitline_tax_clean", clear

lab var ecig_tax_county "E-cigarette tax"

xi: reghdfe calls ecig_tax_county $rhs4 [aw=pop_vary], cl(fips) ab(fips time)
est sto table7
su calls if inrange(rel_time, -1, -1) [aw=pop_vary]
estadd scalar y_pre_treat = r(mean)
su ecig_tax_county [aw=pop_vary]
estadd scalar etax = r(mean)

esttab table7 using "output/table7", $formatf ti("Effect of e-cigarette taxes on calls to quitlines") keep(ecig_tax_county)

********************************************************************************
* FIGURE A2: trends over time in calls for states that adopt and do not adopt an e-cigarette tax

u "workingdata/quitline_tax_clean", clear

g calls_treat = calls if eff_time !=  .
g calls_control = calls if eff_time == .

collapse (mean) calls calls_treat calls_control [aw=pop_vary], by(year) fast

tw (sc calls_treat year, ti("", color(black)) xti("") yti("Calls to state quitlines", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2010(1)2020, valuelabel labsize(small) ) xmtick(2010(1)2020)) (sc calls_control year, ti("", color(black)) xti("") yti("Calls to state quitlines", size(small)) c(l) ylabel(, angle(45) labsize(small)) lcolor(black) lpattern(dash) mcolor(black) xlabel(2010(1)2020, valuelabel labsize(small)) xmtick(2010(1)2020)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono)
graph export "output/afg2.png", replace

********************************************************************************
* FIGURE A5

u "workingdata/quitline_tax_clean", clear

lab var ecig_tax_county "E-cigarette tax"

xi: reghdfe calls $es_ecig_calls $rhs4 [aw=pop_vary] if (inrange(rel_time, -4 ,4) | rel_time == .), cl(fips) ab(fips time)
coefplot, keep($es_ecig_calls_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(4.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Trimmed endpoints", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
 
graph save "temp/calls_trim_x_ecig_es", replace

xi: reghdfe call $es_ecig_calls $rhs4 [aw=pop_vary], cl(fips) ab(fips time)
coefplot, keep($es_ecig_calls_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(4.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Catch all endpoints", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted

graph save "temp/calls_catch_x_ecig_es", replace

* DCDH
u "workingdata/quitline_tax_clean", clear

recode ecig_tax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

did_multiplegt_dyn calls fips time tax_recast, effects(5) placebo(3) controls($rhs4) weight(pop_vary) graph_off save_results("temp/calls_dcdh")

u "temp/calls_dcdh", clear

replace time = time - 1

tw (sc point time, color(black)) (rspike lb up time, color(black)), plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(-0.5, lcolor(black) lpattern(dash)) xlabel(-4(1)4, labsize(small)) xsc(range(-4.5 4.5)) ylabel(, labsize(small) angle(45)) xti("", color(black) size(medium)) ti("DCDH", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) legend(off)

graph save "temp/calls_dcdh", replace

graph combine "temp/calls_trim_x_ecig_es" "temp/calls_catch_x_ecig_es" "temp/calls_dcdh", note("-1 is the omitted category") scheme(s1mono) row(2) ti("", color(black) size(medium)) col(1)
graph export "output/afg5.png", replace


********************************************************************************
*                                    BRFSS                                     *
********************************************************************************
* TABLE 8: Effect of e-cigarette taxes on quit attemps and vaping outcomes using a two-way fixed effects regression: BFRSS survey data 2011-2021;

u if inrange(age, 21, 64) using "workingdata/brfss_tax_clean", clear

lab var ecig_tax_county "E-cigarette tax"

foreach zz in cig_quit_try cig_quit cig_quit_fail {
	xi: reghdfe `zz' ecig_tax_county $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
	est sto table8_`zz'
	su `zz'  if inrange(rel_time, -1, -1)  [aw=_llcpwt]
	estadd scalar y_pre_treat = r(mean)
	su ecig_tax_county  [aw=_llcpwt] if `zz' != .
	estadd scalar etax = r(mean)
}
esttab table8* using "output/table8", $formatg ti("Effect of e-cigarette taxes on quit attempts and vaping outcomes (all ages)") keep(ecig_tax_county)

u if inrange(age, 21, 29) using "workingdata/brfss_tax_clean", clear

lab var ecig_tax_county "E-cigarette tax"

foreach zz in cig_quit_try cig_quit cig_quit_fail {
	xi: reghdfe `zz' ecig_tax_county $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
	est sto table8_`zz'
	su `zz'  if inrange(rel_time, -1, -1)  [aw=_llcpwt]
	estadd scalar y_pre_treat = r(mean)
	su ecig_tax_county  [aw=_llcpwt] if `zz' != .
	estadd scalar etax = r(mean)
}
esttab table8* using "output/table8_2129", $formatg ti("Effect of e-cigarette taxes on quit attempts and vaping outcomes (21-29)") keep(ecig_tax_county)

u if inrange(age, 30, 39) using "workingdata/brfss_tax_clean", clear

lab var ecig_tax_county "E-cigarette tax"

foreach zz in cig_quit_try cig_quit cig_quit_fail {
	xi: reghdfe `zz' ecig_tax_county $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
	est sto table8_`zz'
	su `zz'  if inrange(rel_time, -1, -1)  [aw=_llcpwt]
	estadd scalar y_pre_treat = r(mean)
	su ecig_tax_county  [aw=_llcpwt] if `zz' != .
	estadd scalar etax = r(mean)
}
esttab table8* using "output/table8_3039", $formatg ti("Effect of e-cigarette taxes on quit attempts and vaping outcomes (30-39)") keep(ecig_tax_county)

u if inrange(age, 40, 64) using "workingdata/brfss_tax_clean", clear

lab var ecig_tax_county "E-cigarette tax"

foreach zz in cig_quit_try cig_quit cig_quit_fail {
	xi: reghdfe `zz' ecig_tax_county $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
	est sto table8_`zz'
	su `zz'  if inrange(rel_time, -1, -1)  [aw=_llcpwt]
	estadd scalar y_pre_treat = r(mean)
	su ecig_tax_county  [aw=_llcpwt] if `zz' != .
	estadd scalar etax = r(mean)
}
esttab table8* using "output/table8_4064", $formatg ti("Effect of e-cigarette taxes on quit attempts and vaping outcomes (40-64)") keep(ecig_tax_county)

********************************************************************************
* FIGURE A3: trends over time for BRFSS outcomes

u if inrange(age, 21, 64) using "workingdata/brfss_tax_clean", clear

for zz in any cig_quit_try cig_quit cig_quit_fail any_ecig daily_ecig: g zz_treat = zz if eff_time !=. 
for zz in any cig_quit_try cig_quit cig_quit_fail any_ecig daily_ecig: g zz_control = zz if eff_time == .

collapse (mean) *_treat *_control [pw=_llcpwt], by(year) fast

tw (sc cig_quit_try_treat year, ti("", color(black)) xti("") yti("Quit attempt", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)) (sc cig_quit_try_control year, ti("", color(black)) xti("") yti("Quit attempt", size(small)) c(l) ylabel(, angle(45) labsize(small)) lcolor(black) lpattern(dash) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono) saving("temp/cig_quit_try_trends", replace)

tw (sc cig_quit_treat year, ti("", color(black)) xti("") yti("Quit", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)) (sc cig_quit_control year, ti("", color(black)) xti("") yti("Quit", size(small)) c(l) ylabel(, angle(45) labsize(small)) lcolor(black) lpattern(dash) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono) saving("temp/cig_quit_trends", replace)

tw (sc cig_quit_fail_treat year, ti("", color(black)) xti("") yti("Failed quit attempt", size(small)) c(l) lcolor(black) lpattern(solid) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)) (sc cig_quit_fail_control year, ti("", color(black)) xti("") yti("Failed quit attempt", size(small)) c(l) ylabel(, angle(45) labsize(small)) lcolor(black) lpattern(dash) mcolor(black) xlabel(2011(1)2021, valuelabel labsize(small)) xmtick(2011(1)2021)), leg(label(1 "E-cigarette tax jurisdictions") label(2 "No e-cigarette tax jurisdictions")) leg(size(small) cols(2)) scheme(s1mono)  saving("temp/cig_quit_fail_trends.gph", replace)

grc1leg "temp/cig_quit_try_trends" "temp/cig_quit_trends" "temp/cig_quit_fail_trends", scheme(s1mono) cols(1) legendfrom("temp/cig_quit_fail_trends")
graph export "output/afg3.png", replace

********************************************************************************
* FIGURE A6 & A7: event studies for BRFSS outcomes

u if inrange(age, 21, 64) using "workingdata/brfss_tax_clean", clear

xi: reghdfe cig_quit_try $es_ecig $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Quit attempt", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
graph save "temp/cig_quit_try_catch_x_ecig_es", replace

xi: reghdfe cig_quit $es_ecig $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Sucessful quit", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
graph save "temp/cig_quit_catch_x_ecig_es", replace

xi: reghdfe cig_quit_fail $es_ecig $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Unsuccessful quit", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
graph save "temp/cig_quit_fail_catch_x_ecig_es", replace

graph combine "temp/cig_quit_try_catch_x_ecig_es" "temp/cig_quit_catch_x_ecig_es" "temp/cig_quit_fail_catch_x_ecig_es", note("Catch all endpoints, -1 is the omitted category") scheme(s1mono) row(3) ti("", color(black) size(medium))
graph export "output/afg7.png", replace

keep if inrange(rel_time, -8, 8) | rel_time == .

xi: reghdfe cig_quit_try $es_ecig $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Quit attempt", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
graph save "temp/cig_quit_try_trim_x_ecig_es", replace

xi: reghdfe cig_quit $es_ecig $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Sucessful quit", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
graph save "temp/cig_quit_trim_x_ecig_es", replace

xi: reghdfe cig_quit_fail $es_ecig $rhs3 [pw=_llcpwt], cl(fips) ab(fips time)
coefplot, keep($es_ecig_fig) plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(8.5, lcolor(black) lpattern(dash)) vertical ciopts(lcolor(black)) mcolor(black) levels(95) xlabel(, labsize(small) ) ylabel(, labsize(small) angle(45)) ti("Unsuccessful quit", color(black) size(medium)) xti("", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) omitted
graph save "temp/cig_quit_fail_trim_x_ecig_es", replace

graph combine "temp/cig_quit_try_trim_x_ecig_es" "temp/cig_quit_trim_x_ecig_es" "temp/cig_quit_fail_trim_x_ecig_es", note("Trimmed endpoints, -1 is the omitted category") scheme(s1mono) row(3) ti("", color(black) size(medium))
graph export "output/afg6.png", replace

* DCDH
u if inrange(age, 21, 64) using "workingdata/brfss_tax_clean", clear

recode ecig_tax_county (0/0.5 = 0.50) (0.50000000001/1.0 = 1) (1.0000000000/1.5=1.5) (1.50000000001/2.0=2.0) (2.00000001/max=2.5), g(tax_recast)

foreach zz in cig_quit_try cig_quit cig_quit_fail {
	did_multiplegt_dyn `zz' fips time tax_recast, effects(9) placebo(7) controls($rhs3) weight(pop_vary) graph_off save_results("temp/`zz'_dcdh")

}

foreach zz in cig_quit_try cig_quit cig_quit_fail {
	u "temp/`zz'_dcdh", clear

	if "`zz'" == "cig_quit_try" {
		local title = "Quit attempt"
	}
	else if "`zz'" == "cig_quit" {
		local title = "Sucessful quit"
	}
	else if "`zz'" == "cig_quit_fail" {
		local title = "Unsuccessful quit"
	}
	replace time = time - 1

	tw (sc point time, color(black)) (rspike lb up time, color(black)), plotregion(fcolor(white)) graphregion(fcolor(white)) yline(0, lcolor(black)) xline(-0.5, lcolor(black) lpattern(dash)) xlabel(-8(1)8, labsize(small)) xsc(range(-8.5 8.5)) ylabel(, labsize(small) angle(45)) xti("", color(black) size(medium)) ti("`title'", color(black) size(medium)) yti("Coefficient estimate", color(black) size(small)) legend(off)

	graph save "temp/`zz'_dcdh", replace
}

graph combine "temp/cig_quit_try_dcdh" "temp/cig_quit_dcdh" "temp/cig_quit_fail_dcdh", note("DCDH, -1 is the omitted category")  scheme(s1mono) row(2) ti("", color(black) size(medium)) col(1)
graph export "output/afg8.png", replace


********************************************************************************

u "rawdata/shapefile/usdb", clear
destring GEOID, gen(geoid)

tempfile shapefile
save `shapefile'

u "rawdata/county_core", clear

keep if year == 2021 & quarter == 4

keep state county year quarter ecig_taxstand2cons_y20_cty

ren state fips

ren ecig_taxstand2cons_y20_cty ecig_tax

g geoid = county + fips * 1000

merge 1:m geoid using `shapefile', nogen keep(3)
drop if inlist(fips, 2, 15)

replace ecig_tax = 0 if ecig_tax == .


spmap ecig_tax using "rawdata/shapefile/uscoord", id(id) clm(custom) clbreaks(0 .01 .5 1.5 2.5 100) legorder(lohi) legend(label(2 "No Tax") label(3 "$0.01 to $0.50") label(4 "$0.51 to $1.50") label(5 "$1.51 to $2.50") label(6 ">$2.50") size(medsmall)) fcolor(midblue maroon green gs6 gs12)
graph export "output/fg1.png", replace

log close